var express = require('express');
var router = express.Router();
const userService  = require("../src/services/user/userServices")

/* GET users listing. */
router.post('/login', async function(req, res) {
  let {username,pwd} = req.body;
  let result = await userService.login(username,pwd);
  //console.log(result);
  if(result){
      res.json({"code":1,"msg":"登录成功"});
  }else{
    res.json({"code":0,"msg":"登录失败,用户名或则密码错误"});
  }
});

router.post('/reg', async function(req, res) {
  let {username,pwd} = req.body;
  let result = await userService.registerUser(username,pwd);
  //console.log(result);
  if(result.code){
      res.json({"code":1,"msg":result.msg});
  }else{
    res.json({"code":0,"msg":result.msg});
  }
});


module.exports = router;
